<html>
<head>
	<meta charset="UTF-8">
	<title>流程基本信息新增</title>
	<link id="easyuiTheme"  href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
	<link href="../../static/css/esaas-easyui-edit.css" rel="stylesheet" type="text/css"/>
	<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.cookie.js" type="text/javascript"></script>
	<script src="../../static/easyui/ui-theme.js" type="text/javascript"></script>
	<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
	<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
	<script src="../../ffres/dict/all.js" type="text/javascript"></script>
	<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<body class="easyui-layout">
<form id="ff" method="post">
	<div class="esaas-info-title">流程基本信息信息</div>
	<table class="esaas-info-edit-table">
		<tr hidden="true">
			<td width="15%" align="right">流程标识：</td>
			<td width="35%" hidden="true"><input class="easyui-textbox" type="text"
												 name="bpmId" data-options="required:false"
												 style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr>
			<td width="15%" align="right">流程编号：</td>
			<td width="35%" ><input class="easyui-textbox" type="text"
									id="bpmCode" name="bpmCode" data-options="required:false"
									style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">流程类型：</td>
			<td width="35%"><select class="easyui-combobox"
									id="bpmType" name="bpmType"
									style="width: 100%; height: 25px;"
									readonly="true"
									data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:BPM_TYPE" >
			</select></td>
		</tr>
		<tr>
			<td width="15%" align="right">流程名称：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="bpmName" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right" id="bingfa">任务并发数：</td>
			<td width="35%" id="bingfaValue" ><input class="easyui-textbox" type="text"
													 id="equallyTaskAmount" name="equallyTaskAmount" data-options="required:false"
													 style="width: 100%; height: 25px;"></input></td>
		<tr>
			<td width="15%" align="right">是否允许重跑：</td>
			<td width="35%"><select class="easyui-combobox"
									id="isRunAgain" name="isRunAgain"
									style="width: 100%; height: 25px;"
									data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:STD_PUB_YN">
			</select></td>
			<td width="15%" align="right">子系统代码：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   id="subsCode" name="subsCode" data-options="required:true"
								   style="width: 100%; height: 25px;"></td>
		</tr>
		<tr hidden="true">
			<td width="15%" align="right" hidden="true">创建人：</td>
			<td width="35%" hidden="true"><input class="easyui-textbox" type="text"
												 name="createUser" data-options="required:false"
												 style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">创建时间：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="createTime" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr hidden="true">
			<td width="15%" align="right">最后更新人：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="lastUpdateUser" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
			<td width="15%" align="right">最后更新时间：</td>
			<td width="35%"><input class="easyui-textbox" type="text"
								   name="lastUpdateTime" data-options="required:false"
								   style="width: 100%; height: 25px;"></input></td>
		</tr>
		<tr hidden="true">
			<td width="15%" align="right">是否生效：</td>
			<td width="35%"><select class="easyui-combobox"
									id="effectState" name="effectState"
									style="width: 100%; height: 25px;"
									data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:STD_PUB_YN">
			</select></td>
			<td width="15%" align="right">是否最新版本：</td>
			<td width="35%"><select class="easyui-combobox"
									id="latestState" name="latestState"
									style="width: 100%; height: 25px;"
									data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:STD_PUB_YN">
			</select></td>
		</tr>
	</table>
</form>
<div class="esaas-info-buttons">
	<a href="javascript:void(0)" class="easyui-linkbutton " iconCls="icon-ok" onclick="submitForm()" style="width:90px">&nbsp;保&nbsp;存&nbsp;</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="closeForm()" style="width:90px">&nbsp;关&nbsp;闭&nbsp;</a>
</div>
<script>
	var categoryTag = $.getUrlParam("categoryTag");
	$(function() {
		addTitle("新增");
		var subsCode = $.getUrlParam('subsCode');
		if(subsCode != null){
			$("#subsCode").textbox("setValue", subsCode);
		}
		var bpmType = $.getUrlParam("bpmType");
		$("#bpmType").combobox('setValue', bpmType);
		if("2"==bpmType){
			$('#bingfa').hide();
			$('#bingfaValue').hide();
		}
		if("1"==bpmType){
			$("#equallyTaskAmount").textbox("setValue", "1");
		}
		// $('#chooseOrg').textbox('textbox').bind('click', function() {
		// 	JLEUtil.createModalWin('选择子系统', 'popSubsCodeChoice.html?');
		// });

		$("#effectState").combobox('setValue', 'Y');
		$("#latestState").combobox('setValue', 'Y');


	});

	//保存
	function submitForm() {
		if (!$('#ff').form('validate'))
			return;
		var bpmType = $.getUrlParam("bpmType");
		$("#bpmType").textbox('setText', bpmType);
		var bpmCode = $("#bpmCode").textbox('getValue');
		if(bpmCode.length>32){
			$.messager.alert('错误','流程编号长度超过32!','erro');
			return;
		}
		var jsonData = $("#ff").serializeJson();
		jsonData.categoryTag = categoryTag;
		$.ajax({
			type: 'POST',
			url: '../../api/bpm/base/info',
			data: JSON.stringify(jsonData),
			contentType:"application/json;charset=utf-8",
			dataType:"json",
			async:false,
			success: function(data) {
				if(data == -2){
					$.messager.alert('错误','该流程编号已存在记录！','erro');
				}else if(data == -1){
					$.messager.alert('错误','保存失败！','erro');
				}else {
					$.messager.alert('提示','保存成功！','info',function () {
						window.parent.reloadList();
					});
				}
			}
		});

	};

	//关闭
	function closeForm() {
		window.parent.JLEUtil.closewin();
	}

	// 选择内部服务回调
	function onChooseOrgName(row) {
		$('#ff').form('load', {
			subsCode : row.subsCode
		});
	}

</script>
</body>
</html>
